const TABS = [
  { label: '待办事项', name: '1', num: 0, num_key: 'DB_NUM', permission: ['XXLB_DBSX'] },
  { label: '其他领导关注', name: '2', num: 0, num_key: 'LDGZ_NUM', permission: ['XXLB_LDGZ'] },
  { label: '局领导关注', name: '3', num: 0, num_key: 'JLDGZ_NUM', permission: ['XXLB_JLDGZ'] },
  { label: '我的上报', name: '4', num: 0, num_key: 'WDSB_NUM', permission: ['XXLB_WDSB'] },
  { label: '待上报', name: '5', num: 0, num_key: 'DSB_NUM', permission: ['XXLB_DSB'] },
  { label: '全部', name: '0', num: 0, num_key: 'QB_NUM', permission: ['XXLB_ALL'] }
];
import { mapGetters } from 'vuex';
const tabPermission = {
  computed: {
    ...mapGetters(['permissions'])
  },
  watch: {
    permissions: {
      deep: true,
      immediate: true,
      handler(val) {
        const isHas = (item, val) => {
          for (let ele in item) {
            if (val.find((v) => v === item[ele])) {
              return true;
            }
          }
        };
        TABS.forEach((item) => {
          if (isHas(item.permission, val)) {
            this.tabs.push(item);
          }
        });
        if (this.tabs.length) {
          this.activeTab = this.tabs[0].name;
          this.condition.labelType.value = this.tabs[0].name;
        }
      }
    }
  }
}

export default tabPermission
